/*!
 * @file mean.h
 * @author Yasutomo Kawanishi
 * @date Last Change: 2011/Feb/23.
 * */
#ifndef __BACKGROUND_IMAGE_GENERATOR_MEAN__
#define __BACKGROUND_IMAGE_GENERATOR_MEAN__
#include "common.h"
#include <vector>

class BackgroundImageGeneratorMean{
public:
		BackgroundImageGeneratorMean(int capacity=30);
		~BackgroundImageGeneratorMean();
		BackgroundImageGeneratorMean(const BackgroundImageGeneratorMean& other);
		const BackgroundImageGeneratorMean& operator=(const BackgroundImageGeneratorMean& other);

		void generate(const cv::Mat& src, cv::Mat& dst);
		void update(const cv::Mat& src);
		void train(const std::vector<cv::Mat>& src);

		void save(const std::string& _path)const;
		void load(const std::string& _path);

private:
	bool isInit;
	float alpha;
	cv::Mat average;
	cv::Mat previousUpdate;
	void initialize(const cv::Mat& img);
};
#endif